package com.chainyoung.component_tmperson.ui.mvp.presenter;


import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.ui.mvp.contract.AboutProtocolContact;

import javax.inject.Inject;

@ActivityScope
public class ProtocolPresenter extends BasePresenter<AboutProtocolContact.Model, AboutProtocolContact.View> {

    @Inject
    public ProtocolPresenter(AboutProtocolContact.Model model, AboutProtocolContact.View rootView) {
        super(model, rootView);
    }


    public void getProtocol() {
        addSubscribe(mModel.getProtocol()
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView) {
                    @Override
                    public void onNext(String data) {
                        mView.showProtocol(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }
}
